﻿CREATE PROCEDURE [dbo].[proc_zzjg_Update]
	(
	 @CompanyName nvarchar(50),
	 @Startletter nvarchar(50),	
	 @CompanyPhone nvarchar(50),
	 @CompanyFax nvarchar(50),
	 @CompanyAddress nvarchar(100),
	 @Zip nvarchar(10),
	 @ContactPerson nvarchar(20),
	 @ContactPhone nvarchar(20),
	 @ContactEmail nvarchar(50),
	 @WebAddress nvarchar(50),
	 @Products nvarchar(2000),
	 @Id INT
	 ,@sort VARCHAR(50)
	 
	)
AS
BEGIN TRANSACTION--开始事务
DECLARE @errorSun INT --定义错误计数器
SET @errorSun=0 --没错为0
                --
	UPDATE ManagementArea
	SET

	CompanyName=@CompanyName,
	Startletter=@Startletter,
	
	CompanyPhone=@CompanyPhone,
	CompanyFax=@CompanyFax,
	CompanyAddress=@CompanyAddress,
	Zip=@Zip,
	ContactPerson=@ContactPerson,
	ContactPhone=@ContactPhone,
	ContactEmail=@ContactEmail,
	WebAddress=@WebAddress,
	Products=@Products
	,CompanyNumber = CONVERT(VARCHAR,@sort)
	Where zid=(SELECT bh FROM zzjg WHERE id=@id)
	
	 if @@ROWCOUNT<1
	begin
		set @errorSun=@errorSun+1		
		goto e;
	END
	
	UPDATE zzjg
	SET	
		name = @CompanyName,
		sort = @sort
				
	WHERE id=@id
	
	 if @@ROWCOUNT<1
	begin
		set @errorSun=@errorSun+1		
		goto e;
	END
	
	e:
    PRINT @errorSun
	if @errorSun>0
	begin
		rollback TRANSACTION	
	end
	else
	begin
		commit TRANSACTION
	END
		
	RETURN
